namespace SolidMvvm {
	using System.IO;

	using Newtonsoft.Json;

	using SolidMvvmInterfaces;

	public class SettingString : SettingBase, ISettingString {
		public SettingString(string value) {
			Value = value;
		}

		public string Value { get; }

		public override string ToJSONString() {
			using (var stringWriter = new StringWriter()) {
				using (var jsonTextWriter = new JsonTextWriter(stringWriter) { Formatting = Formatting.Indented })
					jsonTextWriter.WriteValue(Value);
				return stringWriter.ToString();
			}
		}

		public static explicit operator SettingString(string value) {
			return new SettingString(value);
		}

		// Starts on String token
		public static SettingString FromJsonTextReader(JsonTextReader jsonTextReader) {
			return (SettingString)(string)jsonTextReader.Value;
		}
	}
}
